﻿// Program to show the order of destruction of objects using shared_ptr

#include "pch.h"
#include <iostream>
#include <boost/shared_ptr.hpp>

class Base {
public:
    Base() {
        std::cout << "Constructing Base" << std::endl;
    }

    ~Base() {
        std::cout << "Destructing Base" << std::endl;
    }
};

class Derived : public Base {
public:
    Derived() {
        std::cout << "Constructing Derived" << std::endl;
    }

    ~Derived() {
        std::cout << "Destructing Derived" << std::endl;
    }
};

int main()
{
    {
        boost::shared_ptr<Base> sp{ new Derived };
    }
    std::cout << "Hello World!\n";
}

